import sys
from PyQt5.QtWidgets import *
from ReUI import Ui_Form
from PyQt5.QtCore import *

class DemoWindow(QMainWindow,Ui_Form):
    helpSignal=pyqtSignal(str)
    printSignal=pyqtSignal(list)
    previewSignal=pyqtSignal([int,str],[str])
    def __init__(self,parent=None):
        super(DemoWindow,self).__init__(parent)
        self.setupUi(self)
        self.initUI()
    def initUI(self):
        self.helpSignal.connect(self.showHelpMessage)
        self.printSignal.connect(self.printPaper)
        self.previewSignal[str].connect(self.previewPaper)
        self.previewSignal[int,str].connect(self.previewPaperWinthArgs)

        self.printButton.clicked.connect(self.emitPrintSignal)
        self.previewButton.clicked.connect(self.emitPreviewSignal)
    #发射预览的信号
    def emitPreviewSignal(self):
        if self.checkBox.isChecked()==True:


            self.previewSignal[int,str].emit(1080,'充满了整个屏幕')
        elif self.checkBox.isChecked()==False:
            self.previewSignal[str].emit("预览")

    #发射打印信号
    def emitPrintSignal(self):
        plist=[]
        plist.append(self.numberSpinBox.value())
        plist.append(self.styleCombo.currentText())
        self.printSignal.emit(plist)

    def printPaper(self,list):
        self.resultLabel.setText("份数"+str(list[0])+"纸张"+str(list[1]))
    def previewPaperWinthArgs(self,style,text):
        self.resultLabel.setText(str(style)+text)
    def previewPaper(self,text):
        self.resultLabel.setText(text)

    def showHelpMessage(self,msg):
        self.resultLabel.setText(msg)
        self.statusBar().showMessage(msg)
if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=DemoWindow()
    win.show()
    sys.exit(app.exec_())

